package com.sk.waste.app.models

import org.json.JSONObject
import java.io.Serializable
import java.math.BigDecimal

/**
 *  @time 2025/05/01  11:30
 *  @desc 生意
 */
class TenderModel : Serializable {
    var id: String = ""//
    var title: String = ""//
    var image: String = ""//
    var price: String = ""//
    var address: String = ""//
    var categoryId: String = ""//
    var subcategoryId: String = ""//
    var contentText: String = ""//
    var categoryCode: String = ""//
    var categoryName: String = ""//
    var subcategoryCode: String = ""//
    var subcategoryName: String = ""//
    var person: String = ""
    var phone: String = ""
    var linkAddress: String = ""
    var startDate: String = ""
    var endDate: String = ""
    var createTime: String = ""
    var status: String = ""
    var favoriteId: String = "" //收藏id
    var favoriteStatus: String = ""
    var favoriteDate: String = ""
    var wasteInformationId: String = ""

    fun getModelInfo(json: JSONObject) {
        id = json.getString("id")
        title = json.getString("title")
        image = json.getString("image")
        if (!json.isNull("price"))
        {
            price = json.getString("price")
            price = BigDecimal(json.getString("price")).toPlainString()
        }
        address = json.getString("address")
        if (!json.isNull("categoryId"))
        {
            categoryId = json.getString("categoryId")
        }
        if (!json.isNull("subcategoryId"))
        {
            subcategoryId = json.getString("subcategoryId")
        }
        contentText = json.getString("contentText")
        if (!json.isNull("categoryCode"))
        {
            categoryCode = json.getString("categoryCode")
        }
        if (!json.isNull("categoryName"))
        {
            categoryName = json.getString("categoryName")
        }
        if (!json.isNull("subcategoryCode"))
        {
            subcategoryCode = json.getString("subcategoryCode")
        }
        if (!json.isNull("subcategoryName"))
        {
            subcategoryName = json.getString("subcategoryName")
        }
        person = json.getString("person")
        phone = json.getString("phone")
        linkAddress = json.getString("linkAddress")

        if (!json.isNull("startDate"))
        {
            startDate = json.getString("startDate")
        }
        if (!json.isNull("endDate"))
        {
            endDate = json.getString("endDate")
        }
        if (!json.isNull("createTime"))
        {
            createTime = json.getString("createTime")
        }
        if (!json.isNull("status"))
        {
            status = json.getString("status")
        }
        if (!json.isNull("favoriteId"))
        {
            favoriteId = json.getString("favoriteId")
        }
        if (!json.isNull("favoriteStatus"))
        {
            favoriteStatus = json.getString("favoriteStatus")
        }
        if (!json.isNull("favoriteDate"))
        {
            favoriteDate = json.getString("favoriteDate")
        }
        if (!json.isNull("wasteInformationId")) {
            wasteInformationId = json.getString("wasteInformationId")
        }
    }

}